package com.example.mycircle;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.util.AttributeSet;
import android.view.View;

public class MyCircle extends View {
    private Paint paint;

    public MyCircle(Context context,  AttributeSet attrs) {
        super(context, attrs);
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setStyle(Paint.Style.STROKE);

    }

    private int porgress;
    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        paint.setColor(Color.RED);
        paint.setStrokeWidth(20);
        canvas.drawCircle(400,400,200,paint);

        paint.setColor(Color.BLUE);
        paint.setStrokeWidth(4);
        paint.setTextSize(80);
//        canvas.drawText(""+porgress+"%",250,400,paint);

        canvas.drawText(""+porgress+"%",350,400,paint);

        paint.setStrokeWidth(17);
//        canvas.drawArc(100,200,500,
//                600,270,360*porgress/100,false,paint);

        canvas.drawArc(200,200,600,
                600,270,360*porgress/100,false,paint);

    }

    public void setPorgress(int porgress) {
        this.porgress = porgress;
        invalidate();
    }
}
